package esp.proxy.main;

import static esp.basic.config.CommBean.*;

import esp.basic.command.DistCommunication;
import esp.basic.log.ESPLogger;
import esp.basic.business.AndroidCommunicator;
import esp.basic.business.ESP_AndroidBusiness;

public class ProxyAndroid extends ESP_AndroidBusiness {

	public final String instanceID;
	public static AndroidCommunicator proxyCommunicator = null;

	static ESPLogger logger = ESPLogger.getLogger(ProxyAndroid.class.getName());

	public ProxyAndroid(String instanceID, AndroidCommunicator communicator) {
		super(communicator);
		this.instanceID = instanceID;
		proxyCommunicator = communicator;
	}

	// ////////////////////////////////////

	@Override
	public void onConnect() {
		DistCommunication dcProxy = new DistCommunication(
				INSTANCE_ID_STATIC("Proxy"), COMM_TYPE_SEND,
				EXECUTE_STATUS_UNKNOWN, ID_UNKNOWN,
				"proxyServerSychronizeProxy", null);
		proxyCommunicator.sendToServer(dcProxy);
	};

	// /////////////////////////////////////

	public DistCommunication proxyClientSetProxy(DistCommunication dc) {
		DistCommunication dcCk = checkArgSize(dc, 1);
		if (dcCk != null)
			return dcCk;

		String proxyStr = (String) dc.getArgs().get(0);
		logger.info("Proxy Set (Test):\t" + proxyStr);
		return null;
	}
}
